<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>关键点 | 荒岛</title><meta name="author" content="Fi9zero"><meta name="copyright" content="Fi9zero"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="关键点关键点也称为兴趣点，它是 2D 图像或 3D 点云或曲面模型上,可以通过检测标准来获取的具有稳定性、区别性的点集。 NARFNARF（Normal Aligned Radial Feature）关键点是为了从深度图像中识别物体而提出的。 提取要求 提取的过程必须考虑边缘以及物体表面变化信息 即使换了不同的视角，关键点的位置必须稳定的可以被重复探测 关键点所在的位置必须有稳定的支持区域，可以计">
<meta property="og:type" content="article">
<meta property="og:title" content="关键点">
<meta property="og:url" content="https://ckyfi9zero.github.io/2025/08/02/2025-08-02-%E5%85%B3%E9%94%AE%E7%82%B9/index.html">
<meta property="og:site_name" content="荒岛">
<meta property="og:description" content="关键点关键点也称为兴趣点，它是 2D 图像或 3D 点云或曲面模型上,可以通过检测标准来获取的具有稳定性、区别性的点集。 NARFNARF（Normal Aligned Radial Feature）关键点是为了从深度图像中识别物体而提出的。 提取要求 提取的过程必须考虑边缘以及物体表面变化信息 即使换了不同的视角，关键点的位置必须稳定的可以被重复探测 关键点所在的位置必须有稳定的支持区域，可以计">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://ckyfi9zero.github.io/image/avatar.jpg">
<meta property="article:published_time" content="2025-08-02T10:43:00.000Z">
<meta property="article:modified_time" content="2025-08-02T11:24:43.712Z">
<meta property="article:author" content="Fi9zero">
<meta property="article:tag" content="c++">
<meta property="article:tag" content="PCL">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://ckyfi9zero.github.io/image/avatar.jpg"><script type="application/ld+json">{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "关键点",
  "url": "https://ckyfi9zero.github.io/2025/08/02/2025-08-02-%E5%85%B3%E9%94%AE%E7%82%B9/",
  "image": "https://ckyfi9zero.github.io/image/avatar.jpg",
  "datePublished": "2025-08-02T10:43:00.000Z",
  "dateModified": "2025-08-02T11:24:43.712Z",
  "author": [
    {
      "@type": "Person",
      "name": "Fi9zero",
      "url": "https://ckyfi9zero.github.io"
    }
  ]
}</script><link rel="shortcut icon" href="/image/favicon.ico"><link rel="canonical" href="https://ckyfi9zero.github.io/2025/08/02/2025-08-02-%E5%85%B3%E9%94%AE%E7%82%B9/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><script>
    (() => {
      
    const saveToLocal = {
      set: (key, value, ttl) => {
        if (!ttl) return
        const expiry = Date.now() + ttl * 86400000
        localStorage.setItem(key, JSON.stringify({ value, expiry }))
      },
      get: key => {
        const itemStr = localStorage.getItem(key)
        if (!itemStr) return undefined
        const { value, expiry } = JSON.parse(itemStr)
        if (Date.now() > expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return value
      }
    }

    window.btf = {
      saveToLocal,
      getScript: (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        Object.entries(attr).forEach(([key, val]) => script.setAttribute(key, val))
        script.onload = script.onreadystatechange = () => {
          if (!script.readyState || /loaded|complete/.test(script.readyState)) resolve()
        }
        script.onerror = reject
        document.head.appendChild(script)
      }),
      getCSS: (url, id) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onload = link.onreadystatechange = () => {
          if (!link.readyState || /loaded|complete/.test(link.readyState)) resolve()
        }
        link.onerror = reject
        document.head.appendChild(link)
      }),
      addGlobalFn: (key, fn, name = false, parent = window) => {
        if (!false && key.startsWith('pjax')) return
        const globalFn = parent.globalFn || {}
        globalFn[key] = globalFn[key] || {}
        globalFn[key][name || Object.keys(globalFn[key]).length] = fn
        parent.globalFn = globalFn
      }
    }
  
      
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode

      const theme = saveToLocal.get('theme')
    
          theme === 'dark' ? activateDarkMode() : theme === 'light' ? activateLightMode() : null
        
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        document.documentElement.classList.toggle('hide-aside', asideStatus === 'hide')
      }
    
      
    const detectApple = () => {
      if (/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)) {
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
  
    })()
  </script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"未找到符合您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false,"highlightFullpage":false,"highlightMacStyle":true},
  copy: {
    success: '复制成功',
    error: '复制失败',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'null',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyloadPlugin: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '关键点',
  isHighlightShrink: false,
  isToc: true,
  pageType: 'post'
}</script><link rel="stylesheet" href="/css/custom.css"><link rel="stylesheet" href="/css/pig.css"><link rel="stylesheet" href="https://npm.elemecdn.com/ethan4116-blog/lib/css/plane_v2.css"><meta name="generator" content="Hexo 7.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img text-center"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data text-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(/image/per%20page.jpg);"><nav id="nav"><span id="blog-info"><a class="nav-site-title" href="/"><span class="site-name">荒岛</span></a><a class="nav-page-title" href="/"><span class="site-name">关键点</span><span class="site-name"><i class="fa-solid fa-circle-arrow-left"></i><span>  返回首页</span></span></a></span><div id="menus"><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></span></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/booklist/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">关键点</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2025-08-02T10:43:00.000Z" title="发表于 2025-08-02 18:43:00">2025-08-02</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2025-08-02T11:24:43.712Z" title="更新于 2025-08-02 19:24:43">2025-08-02</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/PCL/">PCL</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="container post-content" id="article-container"><h1 id="关键点"><a href="#关键点" class="headerlink" title="关键点"></a>关键点</h1><p>关键点也称为兴趣点，它是 2D 图像或 3D 点云或曲面模型上,可以通过检测标准来获取的具有<strong>稳定性、区别性</strong>的点集。</p>
<h2 id="NARF"><a href="#NARF" class="headerlink" title="NARF"></a>NARF</h2><p>NARF（Normal Aligned Radial Feature）关键点是为了从深度图像中识别物体而提出的。</p>
<h3 id="提取要求"><a href="#提取要求" class="headerlink" title="提取要求"></a>提取要求</h3><ul>
<li>提取的过程必须考虑边缘以及物体表面变化信息</li>
<li>即使换了不同的视角，关键点的位置必须稳定的可以被重复探测</li>
<li>关键点所在的位置必须有稳定的支持区域，可以计算描述子和估计唯一的法向量。</li>
</ul>
<h3 id="探测步骤"><a href="#探测步骤" class="headerlink" title="探测步骤"></a>探测步骤</h3><ol>
<li>遍历每个深度图像点，通过寻找在近邻区域有深度突变的位置进行边缘检测；</li>
<li>遍历每个深度图像点，根据近邻区域的表面变化决定一测度表面变化的系数，以及变化的主方向；</li>
<li>根据第2步找到的主方向计算兴趣值，表征该方向与其他方向的不同，以及该处表面的变化情况，即该点有多稳定；</li>
<li>对兴趣值进行平滑过滤；</li>
<li>进行无最大值压缩找到最终的关键点，即为 NARF 关键点。</li>
</ol>
<h3 id="代码实现"><a href="#代码实现" class="headerlink" title="代码实现"></a>代码实现</h3><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">...</span><br><span class="line"><span class="comment">// 1. 创建或加载范围图像</span></span><br><span class="line">pcl::RangeImage range_image;</span><br><span class="line">range_image.<span class="built_in">createFromPointCloud</span>(point_cloud, angular_resolution, pcl::<span class="built_in">deg2rad</span>(<span class="number">360.0f</span>), pcl::<span class="built_in">deg2rad</span>(<span class="number">180.0f</span>),</span><br><span class="line">                               scene_sensor_pose, coordinate_frame, noise_level, min_range, border_size);</span><br><span class="line"> </span><br><span class="line"><span class="comment">// 2. 设置NARF关键点检测器</span></span><br><span class="line">pcl::RangeImageBorderExtractor range_image_border_extractor;</span><br><span class="line"><span class="function">pcl::NarfKeypoint <span class="title">narf_keypoint_detector</span><span class="params">(&amp;range_image_border_extractor)</span></span>;</span><br><span class="line">narf_keypoint_detector.<span class="built_in">setRangeImage</span>(&amp;range_image);</span><br><span class="line">narf_keypoint_detector.<span class="built_in">getParameters</span>().support_size = support_size;  <span class="comment">// 例如，0.2f</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">// 3. 计算关键点</span></span><br><span class="line">pcl::PointCloud&lt;<span class="type">int</span>&gt; keypoint_indices;</span><br><span class="line">narf_keypoint_detector.<span class="built_in">compute</span>(keypoint_indices);</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
<p>这里创建了一个RangeImageBorderExtractor（距离图像边界提取器）对象，这是进行兴趣点提取所必需的组件。如果您对此感兴趣，可以参考《距离图像边界提取教程》了解更多细节。在本例中，我们直接使用该对象的默认参数配置。</p>
<p>接着我们创建NarfKeypoint（NARF关键点）对象，为其设置：</p>
<ol>
<li>之前创建的RangeImageBorderExtractor对象</li>
<li>输入的距离图像数据</li>
<li>支持区域大小（该球形区域内的点将用于计算兴趣点特征值）</li>
</ol>
<p>被注释掉的代码部分包含可供调试的可选参数。然后我们创建用于存储检测到的关键点索引的对象，并执行关键点计算。最后输出所发现的关键点数量。</p>
<h2 id="SIFT"><a href="#SIFT" class="headerlink" title="SIFT"></a>SIFT</h2><p>SIFT(Scale-Invariant Feature Transform)是一种经典的计算机视觉算法，用于检测和描述图像&#x2F;点云中的局部特征。</p>
<h3 id="主要特点"><a href="#主要特点" class="headerlink" title="主要特点"></a>主要特点</h3><ul>
<li><p>尺度不变性：在不同尺度下都能检测到相同的特征点</p>
</li>
<li><p>旋转不变性：对目标旋转具有鲁棒性</p>
</li>
<li><p>光照不变性：对光照变化不敏感</p>
</li>
<li><p>仿射不变性：对视角变化具有一定适应性</p>
</li>
</ul>
<h3 id="应用原理"><a href="#应用原理" class="headerlink" title="应用原理"></a>应用原理</h3><p>1.尺度空间构建：</p>
<ul>
<li>通过高斯滤波构建不同尺度的点云表示</li>
<li>在不同尺度下检测稳定的关键点<br>2.关键点定位：</li>
<li>在尺度空间中寻找极值点</li>
<li>通过对比度阈值筛选稳定的关键点<br>3.方向分配：</li>
<li>为每个关键点分配主方向（基于点云局部几何特征）<br>4.关键点描述：</li>
<li>生成描述子，表征关键点周围的局部特征</li>
</ul>
<h3 id="代码实现-1"><a href="#代码实现-1" class="headerlink" title="代码实现"></a>代码实现</h3><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">...</span><br><span class="line"><span class="comment">// 1. 设置SIFT关键点检测器</span></span><br><span class="line">pcl::SIFTKeypoint&lt;pcl::PointXYZ, pcl::PointWithScale&gt; sift;</span><br><span class="line">pcl::PointCloud&lt;pcl::PointWithScale&gt; result;</span><br><span class="line">sift.<span class="built_in">setInputCloud</span>(cloud_xyz);</span><br><span class="line"> </span><br><span class="line"><span class="comment">// 2. 配置搜索方法</span></span><br><span class="line">pcl::search::KdTree&lt;pcl::PointXYZ&gt;::<span class="function">Ptr <span class="title">tree</span><span class="params">(<span class="keyword">new</span> pcl::search::KdTree&lt;pcl::PointXYZ&gt;())</span></span>;</span><br><span class="line">sift.<span class="built_in">setSearchMethod</span>(tree);</span><br><span class="line"> </span><br><span class="line"><span class="comment">// 3. 设置尺度参数</span></span><br><span class="line"><span class="type">const</span> <span class="type">float</span> min_scale = <span class="number">0.01f</span>;</span><br><span class="line"><span class="type">const</span> <span class="type">int</span> n_octaves = <span class="number">3</span>;</span><br><span class="line"><span class="type">const</span> <span class="type">int</span> n_scales_per_octave = <span class="number">4</span>;</span><br><span class="line"><span class="type">const</span> <span class="type">float</span> min_contrast = <span class="number">0.005f</span>;</span><br><span class="line">sift.<span class="built_in">setScales</span>(min_scale, n_octaves, n_scales_per_octave);</span><br><span class="line">sift.<span class="built_in">setMinimumContrast</span>(min_contrast);</span><br><span class="line"> </span><br><span class="line"><span class="comment">// 4. 计算关键点</span></span><br><span class="line">sift.<span class="built_in">compute</span>(result);</span><br><span class="line">  ...</span><br></pre></td></tr></table></figure>

<p><img src="https://ckyfi9zero.github.io/picx-images-hosting/20250802/image.wiv9lu6zp.webp" alt="image"></p>
<h2 id="Harris"><a href="#Harris" class="headerlink" title="Harris"></a>Harris</h2><p>Harris 3D关键点检测算法是经典Harris角点检测在三维点云中的扩展，用于检测点云中的特征点（特别是角点特征）</p>
<h3 id="核心思想"><a href="#核心思想" class="headerlink" title="核心思想"></a>核心思想</h3><h4 id="基本原理："><a href="#基本原理：" class="headerlink" title="基本原理："></a>基本原理：</h4><p>基于点云局部表面的曲率变化来检测特征点<br>通过计算每个点的响应值(response value)来衡量其”角点程度”</p>
<h4 id="数学基础："><a href="#数学基础：" class="headerlink" title="数学基础："></a>数学基础：</h4><ul>
<li>构建点云的协方差矩阵</li>
<li>计算矩阵的特征值</li>
<li>通过特征值关系判断点类型(平面点、边缘点、角点)</li>
</ul>
<h3 id="算法特点"><a href="#算法特点" class="headerlink" title="算法特点"></a>算法特点</h3><ul>
<li>对几何变换鲁棒：对旋转、平移具有不变性</li>
<li>对遮挡敏感：局部特征检测，部分遮挡仍可检测</li>
<li>计算效率较高：相比其他3D关键点检测方法</li>
</ul>
<h3 id="代码实现-2"><a href="#代码实现-2" class="headerlink" title="代码实现"></a>代码实现</h3><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">...</span><br><span class="line"><span class="comment">// 1. 设置Harris关键点检测器</span></span><br><span class="line">pcl::HarrisKeypoint3D&lt;pcl::PointXYZ, pcl::PointXYZI, pcl::Normal&gt;* harris_detector = </span><br><span class="line">    <span class="keyword">new</span> pcl::HarrisKeypoint3D&lt;pcl::PointXYZ, pcl::PointXYZI, pcl::Normal&gt;;</span><br><span class="line"> </span><br><span class="line"><span class="comment">// 2. 配置参数</span></span><br><span class="line">harris_detector-&gt;<span class="built_in">setRadius</span>(r_normal);       <span class="comment">// 法线估计半径</span></span><br><span class="line">harris_detector-&gt;<span class="built_in">setRadiusSearch</span>(r_keypoint); <span class="comment">// 关键点搜索半径</span></span><br><span class="line">harris_detector-&gt;<span class="built_in">setInputCloud</span>(input_cloud);</span><br><span class="line"><span class="comment">// harris_detector-&gt;setMethod(pcl::HarrisKeypoint3D&lt;pcl::PointXYZ, pcl::PointXYZI&gt;::LOWE);</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">// 3. 计算关键点</span></span><br><span class="line">pcl::PointCloud&lt;pcl::PointXYZI&gt;::<span class="function">Ptr <span class="title">harris_keypoints</span><span class="params">(<span class="keyword">new</span> pcl::PointCloud&lt;pcl::PointXYZI&gt;())</span></span>;</span><br><span class="line">harris_detector-&gt;<span class="built_in">compute</span>(*harris_keypoints);</span><br><span class="line">...</span><br></pre></td></tr></table></figure>


<h2 id="点聚类算法详解"><a href="#点聚类算法详解" class="headerlink" title="点聚类算法详解"></a>点聚类算法详解</h2><h3 id="基本概念"><a href="#基本概念" class="headerlink" title="基本概念"></a>基本概念</h3><p>点聚类算法（Correspondence Grouping）是3D点云处理中将初始匹配的点对（对应点）聚合成有意义的物体实例的技术。它解决了两个关键问题：</p>
<ol>
<li>从大量噪声匹配中识别出正确的对应关系</li>
<li>将属于同一物体的对应点聚合在一起</li>
</ol>
<h3 id="主要算法类型"><a href="#主要算法类型" class="headerlink" title="主要算法类型"></a>主要算法类型</h3><h4 id="1-Hough3D聚类"><a href="#1-Hough3D聚类" class="headerlink" title="1. Hough3D聚类"></a>1. Hough3D聚类</h4><ul>
<li><strong>原理</strong>：将三维变换空间离散化为投票箱，每个匹配对为其可能的变换参数投票</li>
<li><strong>特点</strong>：<ul>
<li>对噪声和离群点鲁棒</li>
<li>能同时检测多个实例</li>
<li>计算复杂度较高</li>
</ul>
</li>
</ul>
<h4 id="2-几何一致性聚类（Geometric-Consistency）"><a href="#2-几何一致性聚类（Geometric-Consistency）" class="headerlink" title="2. 几何一致性聚类（Geometric Consistency）"></a>2. 几何一致性聚类（Geometric Consistency）</h4><ul>
<li><strong>原理</strong>：检查匹配点之间的几何关系是否一致</li>
<li><strong>特点</strong>：<ul>
<li>更高效</li>
<li>对部分遮挡鲁棒</li>
<li>适合刚性物体识别</li>
</ul>
</li>
</ul>
<h3 id="算法流程"><a href="#算法流程" class="headerlink" title="算法流程"></a>算法流程</h3><ol>
<li><strong>输入</strong>：初始对应点集（可能包含大量错误匹配）</li>
<li><strong>聚类</strong>：<ul>
<li>Hough3D：在变换空间投票</li>
<li>GC：检查几何约束一致性</li>
</ul>
</li>
<li><strong>输出</strong>：<ul>
<li>聚类后的对应点组</li>
<li>估计的物体位姿（旋转矩阵+平移向量）</li>
</ul>
</li>
</ol>
<h3 id="1-关键点检测与描述符计算"><a href="#1-关键点检测与描述符计算" class="headerlink" title="1. 关键点检测与描述符计算"></a>1. 关键点检测与描述符计算</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 均匀采样提取关键点</span></span><br><span class="line">pcl::UniformSampling&lt;PointType&gt; uniform_sampling;</span><br><span class="line">uniform_sampling.<span class="built_in">setInputCloud</span>(model);</span><br><span class="line">uniform_sampling.<span class="built_in">setRadiusSearch</span>(model_ss_);</span><br><span class="line">uniform_sampling.<span class="built_in">filter</span>(*model_keypoints);</span><br><span class="line"></span><br><span class="line"><span class="comment">// SHOT描述符计算</span></span><br><span class="line">pcl::SHOTEstimationOMP&lt;PointType, NormalType, DescriptorType&gt; descr_est;</span><br><span class="line">descr_est.<span class="built_in">setRadiusSearch</span>(descr_rad_);</span><br><span class="line">descr_est.<span class="built_in">setInputCloud</span>(model_keypoints);</span><br><span class="line">descr_est.<span class="built_in">compute</span>(*model_descriptors);</span><br></pre></td></tr></table></figure>

<h3 id="2-对应点匹配"><a href="#2-对应点匹配" class="headerlink" title="2. 对应点匹配"></a>2. 对应点匹配</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// KD树最近邻搜索建立对应关系</span></span><br><span class="line">pcl::KdTreeFLANN&lt;DescriptorType&gt; match_search;</span><br><span class="line">match_search.<span class="built_in">setInputCloud</span>(model_descriptors);</span><br><span class="line">match_search.<span class="built_in">nearestKSearch</span>(scene_descriptors-&gt;<span class="built_in">at</span>(i), <span class="number">1</span>, neigh_indices, neigh_sqr_dists);</span><br></pre></td></tr></table></figure>

<h3 id="3-点聚类核心算法（Hough3D）"><a href="#3-点聚类核心算法（Hough3D）" class="headerlink" title="3. 点聚类核心算法（Hough3D）"></a>3. 点聚类核心算法（Hough3D）</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">pcl::Hough3DGrouping&lt;PointType, PointType, RFType, RFType&gt; clusterer;</span><br><span class="line">clusterer.<span class="built_in">setHoughBinSize</span>(cg_size_);</span><br><span class="line">clusterer.<span class="built_in">setHoughThreshold</span>(cg_thresh_);</span><br><span class="line">clusterer.<span class="built_in">setInputCloud</span>(model_keypoints);</span><br><span class="line">clusterer.<span class="built_in">setSceneCloud</span>(scene_keypoints);</span><br><span class="line">clusterer.<span class="built_in">recognize</span>(rototranslations, clustered_corrs);</span><br></pre></td></tr></table></figure>

<h3 id="关键参数"><a href="#关键参数" class="headerlink" title="关键参数"></a>关键参数</h3><ul>
<li><code>cg_size_</code>：聚类箱大小（Hough）或几何一致性距离阈值（GC）</li>
<li><code>cg_thresh_</code>：投票阈值（Hough）或最小一致匹配数（GC）</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io">Fi9zero</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://ckyfi9zero.github.io/2025/08/02/2025-08-02-%E5%85%B3%E9%94%AE%E7%82%B9/">https://ckyfi9zero.github.io/2025/08/02/2025-08-02-%E5%85%B3%E9%94%AE%E7%82%B9/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来源 <a href="https://ckyfi9zero.github.io" target="_blank">荒岛</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/c/">c++</a><a class="post-meta__tags" href="/tags/PCL/">PCL</a></div><div class="post-share"><div class="social-share" data-image="/image/avatar.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><a class="pagination-related  no-desc" href="/2025/08/02/2025-08-02-RANSAC%E9%9A%8F%E6%9C%BA%E9%87%87%E6%A0%B7%E4%B8%80%E8%87%B4%E6%80%A7/" title="RANSAC随机采样一致性"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info"><div class="info-1"><div class="info-item-1">上一篇</div><div class="info-item-2">RANSAC随机采样一致性</div></div></div></a><a class="pagination-related  no-desc" href="/2025/08/02/2025-08-02-PCL%E4%B8%AD%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F%E7%9B%B8%E5%85%B3%E7%AE%97%E6%B3%95/" title="PCL中深度图像相关算法"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-right"><div class="info-1"><div class="info-item-1">下一篇</div><div class="info-item-2">PCL中深度图像相关算法</div></div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8kdtree%E5%AE%9E%E7%8E%B0%E5%BF%AB%E9%80%9F%E9%A2%86%E5%9F%9F%E6%90%9C%E7%B4%A2/" title="用kdtree实现快速领域搜索"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用kdtree实现快速领域搜索</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8%E5%85%AB%E5%8F%89%E6%A0%91%E8%BF%9B%E8%A1%8C%E6%97%A0%E5%BA%8F%E7%82%B9%E4%BA%91%E6%95%B0%E6%8D%AE%E7%9A%84%E7%A9%BA%E9%97%B4%E5%8F%98%E5%8C%96%E6%A3%80%E6%B5%8B/" title="用八叉树进行无序点云数据的空间变化检测"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用八叉树进行无序点云数据的空间变化检测</div></div></div></a><a class="pagination-related no-desc" href="/2025/07/31/2025-07-31-%E7%94%A8%E7%9B%B4%E9%80%9A%E6%BB%A4%E6%B3%A2%E5%99%A8%E5%AF%B9%E7%82%B9%E4%BA%91%E8%BF%9B%E8%A1%8C%E6%BB%A4%E6%B3%A2%E5%A4%84%E7%90%86/" title="用直通滤波器对点云进行滤波处理"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-07-31</div><div class="info-item-2">用直通滤波器对点云进行滤波处理</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E4%BB%8E%E7%82%B9%E4%BA%91%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E6%B7%B1%E5%BA%A6%E5%9B%BE%E5%83%8F/" title="从点云创建一个深度图像"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">从点云创建一个深度图像</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E4%BB%8E%E4%B8%80%E4%B8%AA%E7%82%B9%E4%BA%91%E4%B8%AD%E6%8F%90%E5%8F%96%E4%B8%80%E4%B8%AA%E5%AD%90%E9%9B%86/" title="从一个点云中提取一个子集"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">从一个点云中提取一个子集</div></div></div></a><a class="pagination-related no-desc" href="/2025/08/01/2025-08-01-%E5%9C%A8%E6%BB%A4%E6%B3%A2%E5%99%A8%E6%A8%A1%E5%9D%97%E7%A7%BB%E9%99%A4%E7%A6%BB%E7%BE%A4%E7%82%B9/" title="在滤波器模块移除离群点"><div class="cover" style="background: var(--default-bg-color)"></div><div class="info text-center"><div class="info-1"><div class="info-item-1"><i class="far fa-calendar-alt fa-fw"></i> 2025-08-01</div><div class="info-item-2">在滤波器模块移除离群点</div></div></div></a></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info text-center"><div class="avatar-img"><img src="/image/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info-name">Fi9zero</div><div class="author-info-description"></div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">54</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">15</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/ckyFi9zero"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons"><a class="social-icon" href="https://github.com/ckyFi9zero" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:2539894206@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%85%B3%E9%94%AE%E7%82%B9"><span class="toc-number">1.</span> <span class="toc-text">关键点</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#NARF"><span class="toc-number">1.1.</span> <span class="toc-text">NARF</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8F%90%E5%8F%96%E8%A6%81%E6%B1%82"><span class="toc-number">1.1.1.</span> <span class="toc-text">提取要求</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8E%A2%E6%B5%8B%E6%AD%A5%E9%AA%A4"><span class="toc-number">1.1.2.</span> <span class="toc-text">探测步骤</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0"><span class="toc-number">1.1.3.</span> <span class="toc-text">代码实现</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#SIFT"><span class="toc-number">1.2.</span> <span class="toc-text">SIFT</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%BB%E8%A6%81%E7%89%B9%E7%82%B9"><span class="toc-number">1.2.1.</span> <span class="toc-text">主要特点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BA%94%E7%94%A8%E5%8E%9F%E7%90%86"><span class="toc-number">1.2.2.</span> <span class="toc-text">应用原理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0-1"><span class="toc-number">1.2.3.</span> <span class="toc-text">代码实现</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Harris"><span class="toc-number">1.3.</span> <span class="toc-text">Harris</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%A0%B8%E5%BF%83%E6%80%9D%E6%83%B3"><span class="toc-number">1.3.1.</span> <span class="toc-text">核心思想</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86%EF%BC%9A"><span class="toc-number">1.3.1.1.</span> <span class="toc-text">基本原理：</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%95%B0%E5%AD%A6%E5%9F%BA%E7%A1%80%EF%BC%9A"><span class="toc-number">1.3.1.2.</span> <span class="toc-text">数学基础：</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%AE%97%E6%B3%95%E7%89%B9%E7%82%B9"><span class="toc-number">1.3.2.</span> <span class="toc-text">算法特点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0-2"><span class="toc-number">1.3.3.</span> <span class="toc-text">代码实现</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%82%B9%E8%81%9A%E7%B1%BB%E7%AE%97%E6%B3%95%E8%AF%A6%E8%A7%A3"><span class="toc-number">1.4.</span> <span class="toc-text">点聚类算法详解</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5"><span class="toc-number">1.4.1.</span> <span class="toc-text">基本概念</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%BB%E8%A6%81%E7%AE%97%E6%B3%95%E7%B1%BB%E5%9E%8B"><span class="toc-number">1.4.2.</span> <span class="toc-text">主要算法类型</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-Hough3D%E8%81%9A%E7%B1%BB"><span class="toc-number">1.4.2.1.</span> <span class="toc-text">1. Hough3D聚类</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%87%A0%E4%BD%95%E4%B8%80%E8%87%B4%E6%80%A7%E8%81%9A%E7%B1%BB%EF%BC%88Geometric-Consistency%EF%BC%89"><span class="toc-number">1.4.2.2.</span> <span class="toc-text">2. 几何一致性聚类（Geometric Consistency）</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%AE%97%E6%B3%95%E6%B5%81%E7%A8%8B"><span class="toc-number">1.4.3.</span> <span class="toc-text">算法流程</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-%E5%85%B3%E9%94%AE%E7%82%B9%E6%A3%80%E6%B5%8B%E4%B8%8E%E6%8F%8F%E8%BF%B0%E7%AC%A6%E8%AE%A1%E7%AE%97"><span class="toc-number">1.4.4.</span> <span class="toc-text">1. 关键点检测与描述符计算</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-%E5%AF%B9%E5%BA%94%E7%82%B9%E5%8C%B9%E9%85%8D"><span class="toc-number">1.4.5.</span> <span class="toc-text">2. 对应点匹配</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-%E7%82%B9%E8%81%9A%E7%B1%BB%E6%A0%B8%E5%BF%83%E7%AE%97%E6%B3%95%EF%BC%88Hough3D%EF%BC%89"><span class="toc-number">1.4.6.</span> <span class="toc-text">3. 点聚类核心算法（Hough3D）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B3%E9%94%AE%E5%8F%82%E6%95%B0"><span class="toc-number">1.4.7.</span> <span class="toc-text">关键参数</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/10/05/2025-10-05-lio_sam/" title="lio_sam">lio_sam</a><time datetime="2025-10-05T02:43:51.000Z" title="发表于 2025-10-05 10:43:51">2025-10-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/12/2025-08-12-%E4%BD%BF%E7%94%A8docker%E6%90%AD%E5%BB%BApytorch%E7%8E%AF%E5%A2%83/" title="使用docker搭建pytorch环境">使用docker搭建pytorch环境</a><time datetime="2025-08-12T12:43:33.000Z" title="发表于 2025-08-12 20:43:33">2025-08-12</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-docker/" title="docker">docker</a><time datetime="2025-08-05T11:02:36.000Z" title="发表于 2025-08-05 19:02:36">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E8%BF%90%E5%8A%A8%E5%AF%B9%E8%B1%A1%E5%88%86%E5%89%B2%E4%B8%8E%E9%85%8D%E5%87%86%E7%AE%97%E6%B3%95/" title="运动对象分割与配准算法">运动对象分割与配准算法</a><time datetime="2025-08-05T08:16:02.000Z" title="发表于 2025-08-05 16:16:02">2025-08-05</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2025/08/05/2025-08-05-%E6%9D%A1%E4%BB%B6%E6%AC%A7%E5%BC%8F%E8%81%9A%E7%B1%BB%E5%88%86%E5%89%B2/" title="条件欧式聚类分割">条件欧式聚类分割</a><time datetime="2025-08-05T07:56:39.000Z" title="发表于 2025-08-05 15:56:39">2025-08-05</time></div></div></div></div></div></div></main><footer id="footer"><div class="footer-other"><div class="footer-copyright"><span class="copyright">&copy;&nbsp;2025 By Fi9zero</span><span class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo 7.3.0</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly 5.4.2</a></span></div><div class="footer_custom_text">Only light can attract bugs.</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><div class="js-pjax"><script>(() => {
  const loadMathjax = () => {
    if (!window.MathJax) {
      window.MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']],
          tags: 'none',
        },
        chtml: {
          scale: 1.1
        },
        options: {
          enableMenu: true,
          renderActions: {
            findScript: [10, doc => {
              for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
                const display = !!node.type.match(/; *mode=display/)
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
                const text = document.createTextNode('')
                node.parentNode.replaceChild(text, node)
                math.start = {node: text, delim: '', n: 0}
                math.end = {node: text, delim: '', n: 0}
                doc.math.push(math)
              }
            }, '']
          }
        }
      }

      const script = document.createElement('script')
      script.src = 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js'
      script.id = 'MathJax-script'
      script.async = true
      document.head.appendChild(script)
    } else {
      MathJax.startup.document.state(0)
      MathJax.texReset()
      MathJax.typesetPromise()
    }
  }

  btf.addGlobalFn('encrypt', loadMathjax, 'mathjax')
  window.pjax ? loadMathjax() : window.addEventListener('load', loadMathjax)
})()</script><script>(() => {
  const runMermaid = ele => {
    window.loadMermaid = true
    const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

    ele.forEach((item, index) => {
      const mermaidSrc = item.firstElementChild
      const mermaidThemeConfig = `%%{init:{ 'theme':'${theme}'}}%%\n`
      const mermaidID = `mermaid-${index}`
      const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent

      const renderFn = mermaid.render(mermaidID, mermaidDefinition)
      const renderMermaid = svg => {
        mermaidSrc.insertAdjacentHTML('afterend', svg)
      }

      // mermaid v9 and v10 compatibility
      typeof renderFn === 'string' ? renderMermaid(renderFn) : renderFn.then(({ svg }) => renderMermaid(svg))
    })
  }

  const codeToMermaid = () => {
    const codeMermaidEle = document.querySelectorAll('pre > code.mermaid')
    if (codeMermaidEle.length === 0) return

    codeMermaidEle.forEach(ele => {
      const preEle = document.createElement('pre')
      preEle.className = 'mermaid-src'
      preEle.hidden = true
      preEle.textContent = ele.textContent
      const newEle = document.createElement('div')
      newEle.className = 'mermaid-wrap'
      newEle.appendChild(preEle)
      ele.parentNode.replaceWith(newEle)
    })
  }

  const loadMermaid = () => {
    if (true) codeToMermaid()
    const $mermaid = document.querySelectorAll('#article-container .mermaid-wrap')
    if ($mermaid.length === 0) return

    const runMermaidFn = () => runMermaid($mermaid)
    btf.addGlobalFn('themeChange', runMermaidFn, 'mermaid')
    window.loadMermaid ? runMermaidFn() : btf.getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaidFn)
  }

  btf.addGlobalFn('encrypt', loadMermaid, 'mermaid')
  window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
})()</script></div><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer data-pjax src="/js/pig.js"></script><script src="/js/weather.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="text-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="站内搜索..." type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>